SER_reduce_black_monday = {
	effect_tooltip = {
		if = {
			limit = { has_idea = SER_black_monday_3 }
			remove_ideas = SER_black_monday_3
		}
		else = {
			swap_ideas = {
				remove_idea = SER_black_monday_1
				add_idea = SER_black_monday_2
			}
		}
	}
	hidden_effect = {
		if = {
			limit = { has_idea = SER_black_monday_1 }
			swap_ideas = {
				remove_idea = SER_black_monday_1
				add_idea = SER_black_monday_2
			}
		}
		else_if = {
			limit = { has_idea = SER_black_monday_2 }
			swap_ideas = {
				remove_idea = SER_black_monday_2
				add_idea = SER_black_monday_3
			}
		}
		else_if = {
			limit = { has_idea = SER_black_monday_3 }
			remove_ideas = SER_black_monday_3
		}
	}
}
SER_reduce_scars = {
	if = {
		limit = { has_idea = SER_scarred_nation_01 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_01
			add_idea = SER_scarred_nation_1
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_1 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_1
			add_idea = SER_scarred_nation_2
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_2 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_2
			add_idea = SER_scarred_nation_3
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_3 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_3
			add_idea = SER_scarred_nation_4
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_4 }
		remove_ideas = SER_scarred_nation_4
	}
}
SER_increase_scars = {
	if = {
		limit = { has_idea = SER_scarred_nation_4 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_4
			add_idea = SER_scarred_nation_3
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_3 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_3
			add_idea = SER_scarred_nation_2
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_2 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_2
			add_idea = SER_scarred_nation_1
		}
	}
	else_if = {
		limit = { has_idea = SER_scarred_nation_1 }
		swap_ideas = {
			remove_idea = SER_scarred_nation_1
			add_idea = SER_scarred_nation_01
		}
	}
	else_if = {
		limit = { SER_has_scarred_nation = no }
		add_ideas = SER_scarred_nation_4
	}
}
SER_recalculate_konspiracija = {
	set_variable = { var_KONS_influence = SER.party_popularity@national_populist }
	multiply_variable = { var_KONS_influence = -1 }
	if = {
		limit = {
			has_completed_focus = SER_the_final_step
		}
		divide_variable = { var_KONS_influence = 2 }
	}
	force_update_dynamic_modifier = yes
}
SER_setup_imro_headquarters = {
	if = {
		limit = { SER = { has_war = no } }
		SER_IMRO_teleport_effect = yes
		SER_IMRO_move_to_lull_phase = yes
		106 = {
			set_variable = { 106.SER_IMRO_compliance_disabled = 1 }
			set_variable = { 106.SER_IMRO_redeployment_disabled = 1 }
			add_dynamic_modifier = { modifier = SER_macedonia_lull_phase }
		}
		SER = {
			country_event = { id = serbia_events.24 days = 2 }
		}
		MAC = {
			set_country_flag = { flag = MAC_dont_attack_grace_period days = 94 value = 1 } #Gives SER a chance to move in and defend Skopje
			country_event = { id = serbia_events.24 days = 2 }
		}
	}
	if = {
		limit = { 106 = { is_core_of = BUL } }
		BUL = {
			remove_state_core = 106
			add_state_claim = 106
		}
	}
	MAC = {
		add_state_core = 106
		set_state_owner = 106
		set_province_controller = 907
		set_province_controller = 3833
		set_province_controller = 6886
		set_province_controller = 13634
		declare_war_on = {
			target = SER
			type = annex_everything
		}
		add_civil_war_target = SER
		division_template = {
			name = "VMRO Diviziya"
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }
				infantry = { x = 1 y = 3 }
			}
			support = {
				recon = { x = 0 y = 0 }
			}
		}
		activate_targeted_decision = { decision = SER_IMRO_victory target = SER }
		activate_targeted_decision = { decision = SER_IMRO_return_to_bulgaria target = BUL }
		complete_national_focus = IMRO_war_of_independence
	}
	106 = {
		if = {
			limit = { has_resistance = yes }
			cancel_resistance = yes
		}
		start_resistance = MAC
		set_compliance = 0
		set_resistance = 40
		add_resistance_target = {
			amount = 30
			occupier = SER
			days = 250
			tooltip = SER_IMRO_start_rt_tt
		}
	}
	if = {
		limit = {
			owns_state = 731
			has_full_control_of_state = 731
		}
		731 = {
			add_core_of = MAC
			set_state_owner_to = MAC
			if = {
				limit = { has_resistance = yes }
				cancel_resistance = yes
			}
			start_resistance = MAC
			set_compliance = 0
			set_resistance = 40
			add_resistance_target = {
				amount = 30
				occupier = SER
				days = 250
				tooltip = SER_IMRO_start_rt_tt
			}
		}
		MAC = { set_province_controller = 3526 }
	}
	add_ideas = SER_IMRO_rebellion
	set_variable = { IMRO_round_system = 1 }
	set_variable = { SER_won_rounds = 0 }
	set_variable = { IMRO_won_rounds = 0 }
	set_global_flag = SER_imro_dont_attack
	activate_mission = SER_IMRO_reb_lull_phase
	activate_mission = SER_IMRO_lull_phase_rounds
	MAC = {
		activate_targeted_decision = { decision = SER_IMRO_open_conflict target = SER }
	}
}

SER_IMRO_disable_rebellion = {
	clr_global_flag = IMRO_attacks_north
	clr_global_flag = IMRO_attacks_south
	clr_global_flag = SER_attacks_north
	clr_global_flag = SER_attacks_south
	clr_global_flag = SER_imro_dont_attack
	MAC = { clr_country_flag = MAC_dont_attack_grace_period }
	hidden_effect = {
		106 = { remove_dynamic_modifier = { modifier = SER_macedonia_lull_phase } }
	}
	SER_IMRO_move_to_action_phase = yes
	clear_variable = 106.SER_IMRO_compliance_disabled
	clear_variable = 106.SER_IMRO_redeployment_disabled
}

SER_IMRO_move_to_action_phase = {
	clear_variable = 106.SER_IMRO_air_efficiency
	clear_variable = 106.SER_IMRO_attrition
	clear_variable = 106.SER_IMRO_army_speed
	clear_variable = 106.SER_IMRO_org_regain
	clear_variable = 106.SER_IMRO_supplies
	106 = { force_update_dynamic_modifier = yes }
}

SER_IMRO_move_to_lull_phase = {
	SER_IMRO_teleport_effect = yes
	country_event = { id = serbia_events.230 hours = 24 }
	set_variable = { 106.SER_IMRO_air_efficiency = -2 }
	set_variable = { 106.SER_IMRO_attrition = 0.1 }
	set_variable = { 106.SER_IMRO_army_speed = -0.75 }
	set_variable = { 106.SER_IMRO_org_regain = -0.75 }
	set_variable = { 106.SER_IMRO_supplies = -0.4 }
	106 = { force_update_dynamic_modifier = yes }
}

SER_IMRO_teleport_effect = {
	if = {
		limit = {
			SER = { check_variable = { enemies^num = 1 } } #Dont teleport armies if SER is at war with more than just MAC
			BUL = { focus_progress = { focus = BUL_macedonia_intervention progress < 0 } } #Dont teleport armies if natpop BUL is about to attack
		}
		every_state = {
			limit = {
				OR = {
					is_owned_by = SER
					is_owned_by = MAC
				}
				OR = {
					state = 106 #Macedonia
					state = 48 #Sofia
					state = 212 #Plovdiv
					state = 769 #Serres
					state = 989 #Chalcidice
					state = 731 #Florina
				}
			}
			teleport_armies = {
				limit = { tag = SER }
				to_state = 765
			}
		}
		106 = { #Macedonia
			teleport_armies = {
				limit = { is_ally_with = SER }
				to_state_array = owned_controlled_states
			}
		}
	}
}

SER_remove_republican_ideas = {
	if = {
		limit = {
			has_idea = SER_workplace_democracy_1
		}
		add_to_array = { SER_former_rep_government_ideas = token:SER_workplace_democracy_1 }
	}
	if = {
		limit = {
			has_idea = SER_workplace_democracy_2
		}
		add_to_array = { SER_former_rep_government_ideas = token:SER_workplace_democracy_2 }
	}
	if = {
		limit = {
			has_idea = SER_rep_political_reform_1
		}
		add_to_array = { SER_former_rep_government_ideas = token:SER_rep_political_reform_1 }
	}
	if = {
		limit = {
			has_idea = SER_rep_political_reform_2
		}
		add_to_array = { SER_former_rep_government_ideas = token:SER_rep_political_reform_2 }
	}
	if = {
		limit = {
			has_idea = SER_harmony_of_classes
		}
		add_to_array = { SER_former_rep_government_ideas = token:SER_harmony_of_classes }
	}
	if = {
		limit = {
			has_idea = SER_national_labor_union_council_idea
		}
		add_to_array = { SER_former_rep_government_ideas = token:SER_national_labor_union_council_idea }
	}
	remove_ideas = {
		SER_workplace_democracy_1
		SER_workplace_democracy_2
		SER_rep_political_reform_1
		SER_rep_political_reform_2
		SER_harmony_of_classes
		SER_national_labor_union_council_idea
	}
}
SER_remove_radical_ideas = {
	if = {
		limit = {
			has_idea = SER_state_corporatism_idea_1
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_state_corporatism_idea_1 }
	}
	if = {
		limit = {
			has_idea = SER_state_corporatism_idea_2
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_state_corporatism_idea_2 }
	}
	if = {
		limit = {
			has_idea = SER_state_corporatism_idea_3
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_state_corporatism_idea_3 }
	}
	if = {
		limit = {
			has_idea = SER_serb_radicalism_1
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_serb_radicalism_1 }
	}
	if = {
		limit = {
			has_idea = SER_serb_radicalism_2
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_serb_radicalism_2 }
	}
	if = {
		limit = {
			has_idea = SER_serb_radicalism_3
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_serb_radicalism_3 }
	}
	if = {
		limit = {
			has_idea = SER_pasic_cult_idea
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_pasic_cult_idea }
	}
	if = {
		limit = {
			has_idea = SER_liberation_of_women_partial
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_liberation_of_women_partial }
	}
	if = {
		limit = {
			has_idea = SER_greenshirts
		}
		add_to_array = { SER_former_rad_government_ideas = token:SER_greenshirts }
	}
	remove_ideas = {
		SER_state_corporatism_idea_1
		SER_state_corporatism_idea_2
		SER_state_corporatism_idea_3
		SER_serb_radicalism_1
		SER_serb_radicalism_2
		SER_serb_radicalism_3
		SER_pasic_cult_idea
		SER_liberation_of_women_partial
		SER_greenshirts
	}
}
SER_remove_revolut_socialist_ideas = {
	remove_ideas = {
		SER_practical_action_program
		SER_practical_action_program_2
		SER_social_welfare_idea
		SER_avant_garde_idea
		SER_avant_garde_idea_2
		SER_socialist_realism_idea
		SER_hotel_slavija
		SER_revolution_purged_army
		SER_revolution_purged_army_2
		SER_revolution_purged_army_2a
		SER_revolution_purged_army_2b
		SER_state_terror
		SER_economic_transformation_initial
		SER_economic_transformation_syndie_1
		SER_economic_transformation_syndie_2
		SER_economic_transformation_serbian_1
		SER_unified_trade_union_idea
		SER_youth_work_brigades_syndie
		SER_youth_work_brigades_notsyndie
	}
}
SER_remove_royalist_ideas = {
	remove_ideas = {
		SER_national_revival
		SER_national_revival_2
		SER_zadruga
		SER_zadruga_2
		SER_military_dominance_idea
		SER_military_dominance_idea_2
		SER_military_dominance_idea_3
		SER_royalist_purged_army
		SER_royalist_purged_army_2
	}
}

SER_add_balkan_claims = {
	add_state_claim = 45 #Vojvodina
	add_state_claim = 102 #Slovenia
	add_state_claim = 103 #Rijeka
	add_state_claim = 104 #Bosnia
	add_state_claim = 109 #Central Croatia
	add_state_claim = 163 #Dalmatia
	add_state_claim = 683 #Gorizia
	add_state_claim = 736 #Istria
	add_state_claim = 794 #Syrmia
	add_state_claim = 841 #Kotor
	add_state_claim = 875 #West Banat
	add_state_claim = 1107 #Karavanks
	add_state_claim = 1109 #Mura
}

SER_enable_yugoslavia_integration = {
	effect_tooltip = {
		every_state = {
			limit = {
				is_yugoslavia = yes
				NOT = { is_core_of = PREV }
			}
			enable_state_integration_50_compliance = yes
		}
	}
	hidden_effect = {
		every_state = {
			limit = {
				is_yugoslavia = yes
				NOT = { has_variable = can_integrate_@PREV }
			}
			set_state_flag = yugoslavia_integration_@PREV
			enable_state_integration_50_compliance = yes
		}
	}
}

SER_disable_yugoslavia_integration = {
	effect_tooltip = {
		every_state = {
			limit = {
				is_yugoslavia = yes
				NOT = { is_core_of = PREV }
			}
			disable_state_integration = yes
		}
	}
	hidden_effect = {
		every_state = {
			limit = { has_state_flag = yugoslavia_integration_@PREV }
			clr_state_flag = yugoslavia_integration_@PREV
			disable_state_integration = yes
		}
	}
}

SER_enable_bulgarian_integration = {
	every_state = {
		limit = {
			region = 26 #Bulgaria
			NOT = { has_variable = can_integrate_@PREV }
		}
		set_state_flag = yugoslavia_integration_@PREV
		enable_state_integration_80_compliance = yes
	}
}

YUG_set_up_yugoslavia_minigame = {
	## Serbia
	set_variable = { YUG_serbia_relations_level = 10 } # Starts at max level
	set_variable = { YUG_serbia_political_power_factor = 0.1 } # starts at 0.1 reduced by -0.05 each level
	set_variable = { YUG_serbia_war_support_factor = 0.05 } # starts at 0.05 reduced by -0.025 each level
	set_variable = { YUG_serbia_army_org_factor = 0.05 } # starts at 0.05 reduced by -0.025 each level
	## Croatia
	set_variable = { YUG_croatia_relations_level = 7 }
	set_variable = { YUG_croatia_political_power_factor = -0.05 } # starts at 0.1 reduced by -0.05 each level
	set_variable = { YUG_croatia_stability_factor = -0.025 } # starts at 0.05 reduced by -0.025 each level
	set_variable = { YUG_croatia_conscription_factor = -0.05 } # starts at 0.1 reduced by -0.05 each level
	## Bosnia
	set_variable = { YUG_bosnia_relations_level = 9 }
	set_variable = { YUG_bosnia_political_power_factor = 0.05 } # starts at 0.1 reduced by -0.05 each level
	set_variable = { YUG_bosnia_stability_factor = 0.025 } # starts at 0.05 reduced by -0.025 each level
	set_variable = { YUG_bosnia_consumer_goods_factor = -0.075 } # starts at -0.15 reduced by 0.075 each level
	## Slovenia
	set_variable = { YUG_slovenia_relations_level = 8 }
	set_variable = { YUG_slovenia_political_power_factor = 0 } # starts at 0.1 reduced by -0.05 each level
	set_variable = { YUG_slovenia_stability_factor = 0 } # starts at 0.05 reduced by -0.025 each level
	set_variable = { YUG_slovenia_industrial_capacity_factory = 0 } # starts at 0.1 reduced by -0.05 each level
	## Other
	set_variable = { YUG_other_relations_level = 8 }
	set_variable = { YUG_other_political_power_factor = 0 } # starts at 0.1 reduced by -0.05 each level
	set_variable = { YUG_other_stability_factor = 0 } # starts at 0.05 reduced by -0.025 each level
	set_variable = { YUG_other_production_speed_buildings_factor = 0 } # starts at 0.1 reduced by -0.05 each level

	### AI variables
	set_variable = { YUG_AI_focus_serbia = 10 }
	divide_variable = { YUG_AI_focus_serbia = YUG_serbia_relations_level }
	clamp_variable = { var = YUG_AI_focus_serbia min = 1 }

	set_variable = { YUG_AI_focus_croatia = 10 }
	divide_variable = { YUG_AI_focus_croatia = YUG_croatia_relations_level }
	clamp_variable = { var = YUG_AI_focus_croatia min = 1 }

	set_variable = { YUG_AI_focus_bosnia = 10 }
	divide_variable = { YUG_AI_focus_bosnia = YUG_bosnia_relations_level }
	clamp_variable = { var = YUG_AI_focus_bosnia min = 1 }

	set_variable = { YUG_AI_focus_slovenia = 10 }
	divide_variable = { YUG_AI_focus_slovenia = YUG_slovenia_relations_level }
	clamp_variable = { var = YUG_AI_focus_slovenia min = 1 }

	set_variable = { YUG_AI_focus_other = 10 }
	divide_variable = { YUG_AI_focus_other = YUG_other_relations_level }
	clamp_variable = { var = YUG_AI_focus_other min = 1 }

	## Setting up Yugoslavia mechanics
	set_variable = { YUG_political_capital = 10 }
	set_variable = { YUG_political_capital_gain = 8 }
	set_variable = { YUG_pc_expenditure_serbia = 0 }
	set_variable = { YUG_pc_expenditure_croatia = 0 }
	set_variable = { YUG_pc_expenditure_bosnia = 0 }
	set_variable = { YUG_pc_expenditure_slovenia = 0 }
	set_variable = { YUG_pc_expenditure_other = 0 }

	hidden_effect = {
		### dummy Serbia so that the correct flag is shown in the decisions
		create_dynamic_country = {
			original_tag = SER
			save_global_event_target_as = SER_dummy
			set_politics = {
				ruling_party = social_liberal
				elections_allowed = no
			}
			reserve_dynamic_country = yes
		}
		every_core_state = { remove_core_of = event_target:SER_dummy }

		add_dynamic_modifier = { modifier = YUG_serbia_dynamic_modifier }
		add_dynamic_modifier = { modifier = YUG_croatia_dynamic_modifier }
		add_dynamic_modifier = { modifier = YUG_bosnia_dynamic_modifier }
		add_dynamic_modifier = { modifier = YUG_slovenia_dynamic_modifier }
		add_dynamic_modifier = { modifier = YUG_other_dynamic_modifier }
		YUG_randomise_pp_requirements = yes
		activate_mission = YUG_rounds_system_mission
		activate_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
		activate_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
		activate_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
		activate_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
		activate_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
	}

	country_event = yugoslavia_mechanics_events.6
}
YUG_refresh_yugoslavia_minigame = {
	# Check situation in Serbia
	set_temp_variable = { checked_state = 1 } # Serbia
	set_temp_variable = { pp_spent = YUG_pc_expenditure_serbia }
	set_temp_variable = { pp_need = YUG_serbia_pp_requirement }
	set_temp_variable = { current_level = YUG_serbia_relations_level }
	YUG_check_ethnic_situation = yes
	YUG_update_ethnic_situation = yes

	# Check situation in Croatia
	set_temp_variable = { checked_state = 2 } # Croatia
	set_temp_variable = { pp_spent = YUG_pc_expenditure_croatia }
	set_temp_variable = { pp_need = YUG_croatia_pp_requirement }
	set_temp_variable = { current_level = YUG_croatia_relations_level }
	YUG_check_ethnic_situation = yes
	YUG_update_ethnic_situation = yes

	# Check situation in Bosnia
	set_temp_variable = { checked_state = 3 } # Bosnia
	set_temp_variable = { pp_spent = YUG_pc_expenditure_bosnia }
	set_temp_variable = { pp_need = YUG_bosnia_pp_requirement }
	set_temp_variable = { current_level = YUG_bosnia_relations_level }
	YUG_check_ethnic_situation = yes
	YUG_update_ethnic_situation = yes

	# Check situation in Slovenia
	set_temp_variable = { checked_state = 4 } # Slovenia
	set_temp_variable = { pp_spent = YUG_pc_expenditure_slovenia }
	set_temp_variable = { pp_need = YUG_slovenia_pp_requirement }
	set_temp_variable = { current_level = YUG_slovenia_relations_level }
	YUG_check_ethnic_situation = yes
	YUG_update_ethnic_situation = yes

	# Check situation in other states
	set_temp_variable = { checked_state = 5 } # Other
	set_temp_variable = { pp_spent = YUG_pc_expenditure_other }
	set_temp_variable = { pp_need = YUG_other_pp_requirement }
	set_temp_variable = { current_level = YUG_other_relations_level }
	YUG_check_ethnic_situation = yes
	YUG_update_ethnic_situation = yes

	#Fire revolts if you are at level 1
	hidden_effect = {
		if = {
			limit = { check_variable = { YUG_croatia_relations_level = 1 } }
			country_event = { id = yugoslavia_mechanics_events.1 hours = 8 }
		}
		if = {
			limit = { check_variable = { YUG_bosnia_relations_level = 1 } }
			country_event = { id = yugoslavia_mechanics_events.2 hours = 12 }
		}
		if = {
			limit = { check_variable = { YUG_slovenia_relations_level = 1 } }
			country_event = { id = yugoslavia_mechanics_events.3 hours = 16 }
		}
	}
	YUG_reset_yugoslavia_missions = yes

	set_variable = { YUG_political_capital = YUG_political_capital_gain }
	set_variable = { YUG_pc_expenditure_serbia = 0 }
	set_variable = { YUG_pc_expenditure_croatia = 0 }
	set_variable = { YUG_pc_expenditure_bosnia = 0 }
	set_variable = { YUG_pc_expenditure_slovenia = 0 }
	set_variable = { YUG_pc_expenditure_other = 0 }
	YUG_randomise_pp_requirements = yes

	activate_mission = YUG_rounds_system_mission
	hidden_effect = { country_event = yugoslavia_mechanics_events.7 }
}

YUG_reset_yugoslavia_missions = {
	if = {
		limit = { NOT = { check_variable = { YUG_decision_counter_serbia = 0 } } }
		remove_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
		remove_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
		remove_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
		remove_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
		remove_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
		activate_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
		set_variable = { YUG_decision_counter_serbia = 0 }
	}
	if = {
		limit = { NOT = { check_variable = { YUG_decision_counter_croatia = 0 } } }
		remove_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
		remove_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
		remove_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
		remove_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
		remove_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
		activate_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
		set_variable = { YUG_decision_counter_croatia = 0 }
	}
	if = {
		limit = { NOT = { check_variable = { YUG_decision_counter_bosnia = 0 } } }
		remove_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
		remove_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
		remove_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
		remove_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
		remove_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
		activate_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
		set_variable = { YUG_decision_counter_bosnia = 0 }
	}
	if = {
		limit = { NOT = { check_variable = { YUG_decision_counter_slovenia = 0 } } }
		remove_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
		remove_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
		remove_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
		remove_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
		remove_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
		activate_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
		set_variable = { YUG_decision_counter_slovenia = 0 }
	}
	if = {
		limit = { NOT = { check_variable = { YUG_decision_counter_other = 0 } } }
		remove_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
		remove_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
		remove_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
		remove_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
		remove_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
		activate_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
		set_variable = { YUG_decision_counter_other = 0 }
	}
}

YUG_randomise_pp_requirements = {
	hidden_effect = {
		### Serbia
		random_list = {
			10 = {
				modifier = {
					factor = 2
					check_variable = { YUG_serbia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_serbia_pp_requirement = 1 }
			}
			30 = {
				modifier = {
					factor = 3
					check_variable = { YUG_serbia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_serbia_pp_requirement = 2 }
			}
			30 = { set_variable = { YUG_serbia_pp_requirement = 3 } }
			20 = { set_variable = { YUG_serbia_pp_requirement = 4 } }
			10 = {
				modifier = {
					factor = 0
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_serbia_pp_requirement = 5 }
			}
		}

		### Croatia
		random_list = {
			10 = {
				modifier = {
					factor = 2
					check_variable = { YUG_croatia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				modifier = {
					factor = 0
					has_country_flag = YUG_orjuna_is_established
				}
				modifier = {
					factor = 0
					has_country_flag = YUG_ustase_is_established
				}
				set_variable = { YUG_croatia_pp_requirement = 1 }
			}
			10 = {
				modifier = {
					factor = 3
					check_variable = { YUG_croatia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				modifier = {
					factor = 0
					has_country_flag = YUG_ustase_is_established
				}
				set_variable = { YUG_croatia_pp_requirement = 2 }
			}
			20 = {
				modifier = {
					factor = 0
					has_country_flag = YUG_ustase_is_established
				}
				set_variable = { YUG_croatia_pp_requirement = 3 }
			}
			30 = {
				modifier = {
					factor = 2
					has_country_flag = YUG_orjuna_is_established
				}
				set_variable = { YUG_croatia_pp_requirement = 4 }
			}
			30 = {
				modifier = {
					factor = 0
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
					NOT = { has_country_flag = YUG_orjuna_is_established }
					NOT = { has_country_flag = YUG_ustase_is_established }
				}
				modifier = {
					factor = 1.5
					has_country_flag = YUG_ustase_is_established
				}
				modifier = {
					factor = 1.2
					has_country_flag = YUG_orjuna_is_established
				}
				set_variable = { YUG_croatia_pp_requirement = 5 }
			}
		}

		### Bosnia
		random_list = {
			20 = {
				modifier = {
					factor = 2
					check_variable = { YUG_bosnia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_bosnia_pp_requirement = 1 }
			}
			20 = {
				modifier = {
					factor = 3
					check_variable = { YUG_bosnia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_bosnia_pp_requirement = 2 }
			}
			30 = { set_variable = { YUG_bosnia_pp_requirement = 3 } }
			20 = {
				modifier = {
					factor = 0
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
					OR = {
						has_completed_focus = SER_YUG_rep_renew_precani_settlement
						has_completed_focus = SER_YUG_royal_rep_renew_precani_settlement
					}
				}
				set_variable = { YUG_bosnia_pp_requirement = 4 }
			}
			10 = {
				modifier = {
					factor = 0
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
						has_completed_focus = SER_YUG_rep_renew_precani_settlement
						has_completed_focus = SER_YUG_royal_rep_renew_precani_settlement
					}
				}
				set_variable = { YUG_bosnia_pp_requirement = 5 }
			}
		}

		### Slovenia
		random_list = {
			20 = {
				modifier = {
					factor = 2
					check_variable = { YUG_slovenia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_slovenia_pp_requirement = 1 }
			}
			20 = {
				modifier = {
					factor = 3
					check_variable = { YUG_slovenia_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_slovenia_pp_requirement = 2 }
			}
			20 = { set_variable = { YUG_slovenia_pp_requirement = 3 } }
			20 = { set_variable = { YUG_slovenia_pp_requirement = 4 } }
			20 = {
				modifier = {
					factor = 0
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_slovenia_pp_requirement = 5 }
			}
		}

		### Others
		random_list = {
			30 = {
				modifier = {
					factor = 2
					check_variable = { YUG_other_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_other_pp_requirement = 1 }
			}
			10 = {
				modifier = {
					factor = 3
					check_variable = { YUG_other_relations_level < 5 }
				}
				modifier = {
					factor = 2
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_other_pp_requirement = 2 }
			}
			10 = { set_variable = { YUG_other_pp_requirement = 3 } }
			30 = { set_variable = { YUG_other_pp_requirement = 4 } }
			20 = {
				modifier = {
					factor = 0
					OR = {
						has_completed_focus = SER_YUG_federal_constitution
						has_completed_focus = SER_YUG_royal_federal_constitution
					}
				}
				set_variable = { YUG_other_pp_requirement = 5 }
			}
		}

		YUG_update_AI_variables = yes
	}
}

YUG_update_AI_variables = {
	YUG_update_AI_variables_serbia = yes
	YUG_update_AI_variables_croatia = yes
	YUG_update_AI_variables_bosnia = yes
	YUG_update_AI_variables_slovenia = yes
	YUG_update_AI_variables_other = yes
}

YUG_update_AI_variables_serbia = {
	set_variable = { YUG_AI_target_serbia = YUG_serbia_pp_requirement } #used as targets for AI spending
	if = {
		limit = { check_variable = { YUG_serbia_relations_level < 10 } }
		add_to_variable = { YUG_AI_target_serbia = 1 }
	}

	set_variable = { YUG_AI_factor_serbia = 5 }
	divide_variable = { YUG_AI_factor_serbia = YUG_serbia_pp_requirement } #used to make the AI focus on smaller requirements first
	clamp_variable = { var = YUG_AI_factor_serbia min = 1 }
}

YUG_update_AI_variables_croatia = {
	set_variable = { YUG_AI_target_croatia = YUG_croatia_pp_requirement }
	if = {
		limit = { check_variable = { YUG_croatia_relations_level < 10 } }
		add_to_variable = { YUG_AI_target_croatia = 1 }
	}

	set_variable = { YUG_AI_factor_croatia = 5 }
	divide_variable = { YUG_AI_factor_croatia = YUG_croatia_pp_requirement }
	clamp_variable = { var = YUG_AI_factor_croatia min = 1 }
}

YUG_update_AI_variables_bosnia = {
	set_variable = { YUG_AI_target_bosnia = YUG_bosnia_pp_requirement }
	if = {
		limit = { check_variable = { YUG_bosnia_relations_level < 10 } }
		add_to_variable = { YUG_AI_target_bosnia = 1 }
	}

	set_variable = { YUG_AI_factor_bosnia = 5 }
	divide_variable = { YUG_AI_factor_bosnia = YUG_bosnia_pp_requirement }
	clamp_variable = { var = YUG_AI_factor_bosnia min = 1 }
}

YUG_update_AI_variables_slovenia = {
	set_variable = { YUG_AI_target_slovenia = YUG_slovenia_pp_requirement }
	if = {
		limit = { check_variable = { YUG_slovenia_relations_level < 10 } }
		add_to_variable = { YUG_AI_target_slovenia = 1 }
	}

	set_variable = { YUG_AI_factor_slovenia = 5 }
	divide_variable = { YUG_AI_factor_slovenia = YUG_slovenia_pp_requirement }
	clamp_variable = { var = YUG_AI_factor_slovenia min = 1 }
}

YUG_update_AI_variables_other = {
	set_variable = { YUG_AI_target_other = YUG_other_pp_requirement }
	if = {
		limit = { check_variable = { YUG_other_relations_level < 10 } }
		add_to_variable = { YUG_AI_target_other = 1 }
	}

	set_variable = { YUG_AI_factor_other = 5 }
	divide_variable = { YUG_AI_factor_other = YUG_other_pp_requirement }
	clamp_variable = { var = YUG_AI_factor_other min = 1 }
}

YUG_check_ethnic_situation = {
	if = {
		limit = {
			check_variable = { pp_spent > pp_need }
			check_variable = { current_level < 10 }
		}
		set_temp_variable = { ethnic_situation = 1 } # 1 = +1 relations level
	}
	else_if = {
		limit = {
			check_variable = { pp_spent < pp_need }
			check_variable = { current_level > 1 }
		}
		set_temp_variable = { ethnic_situation = -1 } # -1 = -1 relations level
	}
	else = {
		set_temp_variable = { ethnic_situation = 0 }
	}
}
YUG_update_ethnic_situation = {
	if = {
		limit = {
			check_variable = { checked_state = 1 }
		}
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_serbia_political_power_factor = gains }
		set_temp_variable = { gains = 0.025 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_serbia_war_support_factor = gains }
		set_temp_variable = { gains = 0.025 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_serbia_army_org_factor = gains }

		add_to_variable = { YUG_serbia_relations_level = ethnic_situation }

		### AI variables
		set_variable = { YUG_AI_focus_serbia = 10 }
		divide_variable = { YUG_AI_focus_serbia = YUG_serbia_relations_level }
		clamp_variable = { var = YUG_AI_focus_serbia min = 1 }
	}
	else_if = {
		limit = {
			check_variable = { checked_state = 2 }
		}
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_croatia_political_power_factor = gains }
		set_temp_variable = { gains = 0.025 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_croatia_stability_factor = gains }
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_croatia_conscription_factor = gains }

		add_to_variable = { YUG_croatia_relations_level = ethnic_situation }

		### AI variables
		set_variable = { YUG_AI_focus_croatia = 10 }
		divide_variable = { YUG_AI_focus_croatia = YUG_croatia_relations_level }
		clamp_variable = { var = YUG_AI_focus_croatia min = 1 }
	}
	else_if = {
		limit = {
			check_variable = { checked_state = 3 }
		}
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_bosnia_political_power_factor = gains }
		set_temp_variable = { gains = 0.025 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_bosnia_stability_factor = gains }
		set_temp_variable = { gains = -0.075 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_bosnia_consumer_goods_factor = gains }

		add_to_variable = { YUG_bosnia_relations_level = ethnic_situation }

		### AI variables
		set_variable = { YUG_AI_focus_bosnia = 10 }
		divide_variable = { YUG_AI_focus_bosnia = YUG_bosnia_relations_level }
		clamp_variable = { var = YUG_AI_focus_bosnia min = 1 }
	}
	else_if = {
		limit = {
			check_variable = { checked_state = 4 }
		}
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_slovenia_political_power_factor = gains }
		set_temp_variable = { gains = 0.025 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_slovenia_stability_factor = gains }
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_slovenia_industrial_capacity_factory = gains }

		add_to_variable = { YUG_slovenia_relations_level = ethnic_situation }

		### AI variables
		set_variable = { YUG_AI_focus_slovenia = 10 }
		divide_variable = { YUG_AI_focus_slovenia = YUG_slovenia_relations_level }
		clamp_variable = { var = YUG_AI_focus_slovenia min = 1 }
	}
	else_if = {
		limit = {
			check_variable = { checked_state = 5 }
		}
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_other_political_power_factor = gains }
		set_temp_variable = { gains = 0.025 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_other_stability_factor = gains }
		set_temp_variable = { gains = 0.05 }
		multiply_temp_variable = { gains = ethnic_situation }
		add_to_variable = { YUG_other_production_speed_buildings_factor = gains }

		add_to_variable = { YUG_other_relations_level = ethnic_situation }

		### AI variables
		set_variable = { YUG_AI_focus_other = 10 }
		divide_variable = { YUG_AI_focus_other = YUG_other_relations_level }
		clamp_variable = { var = YUG_AI_focus_other min = 1 }
	}
}
YUG_update_expenditure_missions = {
	YUG_update_expenditure_missions_serbia = yes
	YUG_update_expenditure_missions_croatia = yes
	YUG_update_expenditure_missions_bosnia = yes
	YUG_update_expenditure_missions_slovenia = yes
	YUG_update_expenditure_missions_other = yes
}
YUG_update_expenditure_missions_serbia = {
	clamp_variable = { var = YUG_pc_expenditure_serbia max = 10 min = 0 }
	hidden_effect = {
		if = {
			limit = {
				check_variable = { YUG_pc_expenditure_serbia = 0 }
				NOT = { check_variable = { YUG_decision_counter_serbia = 0 } }
			}
			remove_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
			activate_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
			set_variable = { YUG_decision_counter_serbia = 0 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_serbia = 1 }
				NOT = { check_variable = { YUG_decision_counter_serbia = 1 } }
			}
			remove_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
			activate_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
			set_variable = { YUG_decision_counter_serbia = 1 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_serbia = 2 }
				NOT = { check_variable = { YUG_decision_counter_serbia = 2 } }
			}
			remove_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
			activate_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
			set_variable = { YUG_decision_counter_serbia = 2 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_serbia = 3 }
				NOT = { check_variable = { YUG_decision_counter_serbia = 3 } }
			}
			remove_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
			activate_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
			set_variable = { YUG_decision_counter_serbia = 3 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_serbia = 4 }
				NOT = { check_variable = { YUG_decision_counter_serbia = 4 } }
			}
			remove_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
			activate_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
			set_variable = { YUG_decision_counter_serbia = 4 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_serbia > 4 }
				NOT = { check_variable = { YUG_decision_counter_serbia = 5 } }
			}
			remove_targeted_decision = { decision = YUG_serbia_expenditure_0 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_1 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_2 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_3 target = event_target:SER_dummy }
			remove_targeted_decision = { decision = YUG_serbia_expenditure_4 target = event_target:SER_dummy }
			activate_targeted_decision = { decision = YUG_serbia_expenditure_5 target = event_target:SER_dummy }
			set_variable = { YUG_decision_counter_serbia = 5 }
		}
	}
}
YUG_update_expenditure_missions_croatia = {
	clamp_variable = { var = YUG_pc_expenditure_croatia max = 10 min = 0 }
	hidden_effect = {
		if = {
			limit = {
				check_variable = { YUG_pc_expenditure_croatia = 0 }
				NOT = { check_variable = { YUG_decision_counter_croatia = 0 } }
			}
			remove_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
			activate_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
			set_variable = { YUG_decision_counter_croatia = 0 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_croatia = 1 }
				NOT = { check_variable = { YUG_decision_counter_croatia = 1 } }
			}
			remove_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
			activate_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
			set_variable = { YUG_decision_counter_croatia = 1 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_croatia = 2 }
				NOT = { check_variable = { YUG_decision_counter_croatia = 2 } }
			}
			remove_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
			activate_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
			set_variable = { YUG_decision_counter_croatia = 2 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_croatia = 3 }
				NOT = { check_variable = { YUG_decision_counter_croatia = 3 } }
			}
			remove_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
			activate_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
			set_variable = { YUG_decision_counter_croatia = 3 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_croatia = 4 }
				NOT = { check_variable = { YUG_decision_counter_croatia = 4 } }
			}
			remove_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
			activate_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
			set_variable = { YUG_decision_counter_croatia = 4 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_croatia > 4 }
				NOT = { check_variable = { YUG_decision_counter_croatia = 5 } }
			}
			remove_targeted_decision = { decision = YUG_croatia_expenditure_0 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_1 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_2 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_3 target = CRO }
			remove_targeted_decision = { decision = YUG_croatia_expenditure_4 target = CRO }
			activate_targeted_decision = { decision = YUG_croatia_expenditure_5 target = CRO }
			set_variable = { YUG_decision_counter_croatia = 5 }
		}
	}
}
YUG_update_expenditure_missions_bosnia = {
	clamp_variable = { var = YUG_pc_expenditure_bosnia max = 10 min = 0 }
	hidden_effect = {
		if = {
			limit = {
				check_variable = { YUG_pc_expenditure_bosnia = 0 }
				NOT = { check_variable = { YUG_decision_counter_bosnia = 0 } }
			}
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
			activate_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
			set_variable = { YUG_decision_counter_bosnia = 0 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_bosnia = 1 }
				NOT = { check_variable = { YUG_decision_counter_bosnia = 1 } }
			}
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
			activate_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
			set_variable = { YUG_decision_counter_bosnia = 1 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_bosnia = 2 }
				NOT = { check_variable = { YUG_decision_counter_bosnia = 2 } }
			}
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
			activate_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
			set_variable = { YUG_decision_counter_bosnia = 2 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_bosnia = 3 }
				NOT = { check_variable = { YUG_decision_counter_bosnia = 3 } }
			}
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
			activate_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
			set_variable = { YUG_decision_counter_bosnia = 3 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_bosnia = 4 }
				NOT = { check_variable = { YUG_decision_counter_bosnia = 4 } }
			}
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
			activate_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
			set_variable = { YUG_decision_counter_bosnia = 4 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_bosnia > 4 }
				NOT = { check_variable = { YUG_decision_counter_bosnia = 5 } }
			}
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_0 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_1 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_2 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_3 target = BOS }
			remove_targeted_decision = { decision = YUG_bosnia_expenditure_4 target = BOS }
			activate_targeted_decision = { decision = YUG_bosnia_expenditure_5 target = BOS }
			set_variable = { YUG_decision_counter_bosnia = 5 }
		}
	}
}
YUG_update_expenditure_missions_slovenia = {
	clamp_variable = { var = YUG_pc_expenditure_slovenia max = 10 min = 0 }
	hidden_effect = {
		if = {
			limit = {
				check_variable = { YUG_pc_expenditure_slovenia = 0 }
				NOT = { check_variable = { YUG_decision_counter_slovenia = 0 } }
			}
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
			activate_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
			set_variable = { YUG_decision_counter_slovenia = 0 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_slovenia = 1 }
				NOT = { check_variable = { YUG_decision_counter_slovenia = 1 } }
			}
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
			activate_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
			set_variable = { YUG_decision_counter_slovenia = 1 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_slovenia = 2 }
				NOT = { check_variable = { YUG_decision_counter_slovenia = 2 } }
			}
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
			activate_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
			set_variable = { YUG_decision_counter_slovenia = 2 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_slovenia = 3 }
				NOT = { check_variable = { YUG_decision_counter_slovenia = 3 } }
			}
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
			activate_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
			set_variable = { YUG_decision_counter_slovenia = 3 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_slovenia = 4 }
				NOT = { check_variable = { YUG_decision_counter_slovenia = 4 } }
			}
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
			activate_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
			set_variable = { YUG_decision_counter_slovenia = 4 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_slovenia > 4 }
				NOT = { check_variable = { YUG_decision_counter_slovenia = 5 } }
			}
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_0 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_1 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_2 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_3 target = SLV }
			remove_targeted_decision = { decision = YUG_slovenia_expenditure_4 target = SLV }
			activate_targeted_decision = { decision = YUG_slovenia_expenditure_5 target = SLV }
			set_variable = { YUG_decision_counter_slovenia = 5 }
		}
	}
}
YUG_update_expenditure_missions_other = {
	clamp_variable = { var = YUG_pc_expenditure_other max = 10 min = 0 }
	hidden_effect = {
		if = {
			limit = {
				check_variable = { YUG_pc_expenditure_other = 0 }
				NOT = { check_variable = { YUG_decision_counter_other = 0 } }
			}
			remove_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
			activate_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
			set_variable = { YUG_decision_counter_other = 0 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_other = 1 }
				NOT = { check_variable = { YUG_decision_counter_other = 1 } }
			}
			remove_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
			activate_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
			set_variable = { YUG_decision_counter_other = 1 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_other = 2 }
				NOT = { check_variable = { YUG_decision_counter_other = 2 } }
			}
			remove_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
			activate_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
			set_variable = { YUG_decision_counter_other = 2 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_other = 3 }
				NOT = { check_variable = { YUG_decision_counter_other = 3 } }
			}
			remove_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
			activate_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
			set_variable = { YUG_decision_counter_other = 3 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_other = 4 }
				NOT = { check_variable = { YUG_decision_counter_other = 4 } }
			}
			remove_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
			activate_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
			set_variable = { YUG_decision_counter_other = 4 }
		}
		else_if = {
			limit = {
				check_variable = { YUG_pc_expenditure_other > 4 }
				NOT = { check_variable = { YUG_decision_counter_other = 5 } }
			}
			remove_targeted_decision = { decision = YUG_other_expenditure_0 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_1 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_2 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_3 target = ALB }
			remove_targeted_decision = { decision = YUG_other_expenditure_4 target = ALB }
			activate_targeted_decision = { decision = YUG_other_expenditure_5 target = ALB }
			set_variable = { YUG_decision_counter_other = 5 }
		}
	}
}

YUG_bulgarian_integration_relations_effect = {
	if = {
		limit = { NOT = { has_completed_focus = SER_YUG_brotherhood_and_unity } }
		set_temp_variable = { ethnic_situation = 5 }
		clamp_temp_variable = { var = ethnic_situation min = 1 max = YUG_other_relations_level }
		subtract_from_temp_variable = { ethnic_situation = 1 }
		multiply_temp_variable = { ethnic_situation = -1 }
		if = {
			limit = { check_variable = { ethnic_situation < 0 } }
			set_temp_variable = { checked_state = 5 } # Other
			custom_effect_tooltip = YUG_other_reduce_relations_tt
			YUG_update_ethnic_situation = yes
		}
		set_temp_variable = { gained_pp_per_turn = -3 }
		custom_effect_tooltip = YUG_modify_pp_gain_decrease_tt
		add_to_variable = { YUG_political_capital_gain = gained_pp_per_turn }
	}
}

YUG_spawn_slovenia_rebellion = {
	SLV = {
		add_state_core = 102
		transfer_state = 102
		set_war_support = 0.9
		SLV_move_back_generals = yes
		add_ideas = {
			SER_YUG_anti_serb_rebellion
			war_economy
			closed_economy
			service_by_requirement
		}
		set_party_name = {
			ideology = social_democrat
			name = SER_slovene_liberation_front
			long_name = SER_slovene_liberation_front_long
		}
		division_template = {
			name = "Vaške straže"
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }
			}
		}
		102 = {
			create_unit = {
				division = "division_template = \"Vaške straže\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Vaške straže\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Vaške straže\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
		}
	}
	declare_war_on = {
		target = SLV
		type = annex_everything
	}
}
YUG_spawn_croatia_rebellion = {
	CRO_reset_cores_and_claims = yes
	every_owned_state = {
		limit = {
			is_core_of = CRO
			is_controlled_by = ROOT
		}
		transfer_state_to = CRO
	}
	every_character = {
		limit = { has_character_flag = former_CRO }
		set_nationality = {
			target_country = CRO
			character = THIS
		}
	}
	CRO = {
		set_capital = { state = 109 }
		set_politics = {
			ruling_party = paternal_autocrat
			elections_allowed = no
		}
		add_ideas = {
			SER_YUG_anti_serb_rebellion
			war_economy
			closed_economy
			service_by_requirement
		}
		set_war_support = 0.9
		CRO_slavko_kvaternik = {
			if = {
				limit = { has_ideology = paternal_autocrat_subtype }
				promote_character = paternal_autocrat_subtype
			}
			else = {
				add_country_leader_role = {
					country_leader = {
						desc = CRO_slavko_kvaternik_army_chief_desc
						ideology = paternal_autocrat_subtype
					}
					promote_leader = yes
				}
			}
		}
		set_popularities = {
			totalist = 0
			radical_socialist = 3
			syndicalist = 2
			social_democrat = 5
			social_liberal = 15
			market_liberal = 0
			social_conservative = 5
			authoritarian_democrat = 3
			paternal_autocrat = 40
			national_populist = 27
		}
		division_template = {
			name = "Hrvatsko domobranstvo"
			division_names_group = CRO_INF_01
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }
			}
			support = {
				recon = { x = 0 y = 0 }
			}
		}
		109 = {
			create_unit = {
				division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
		}
		if = {
			limit = { 103 = { is_owned_by = PREV } }
			103 = {
				create_unit = {
					division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
					allow_spawning_on_enemy_provs = yes
					owner = PREV
				}
			}
		}
		if = {
			limit = { 163 = { is_owned_by = PREV } }
			163 = {
				create_unit = {
					division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
					allow_spawning_on_enemy_provs = yes
					owner = PREV
				}
				create_unit = {
					division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
					allow_spawning_on_enemy_provs = yes
					owner = PREV
				}
			}
		}
		794 = {
			create_unit = {
				division = "division_template = \"Hrvatsko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
		}
	}
	declare_war_on = {
		target = CRO
		type = annex_everything
	}
	if = {
		limit = {
			103 = { is_owned_and_controlled_by = CRO }
		}
		set_province_controller = 984
	}
	if = {
		limit = {
			109 = { is_owned_and_controlled_by = CRO }
		}
		set_province_controller = 9595
		set_province_controller = 3627
	}
	if = {
		limit = {
			794 = { is_owned_and_controlled_by = CRO }
		}
		set_province_controller = 11577
	}
}
YUG_spawn_bosnia_rebellion = {
	BOS = {
		add_state_core = 104
		transfer_state = 104
		set_capital = { state = 104 }

		set_politics = {
			ruling_party = social_conservative
			elections_allowed = no
		}
		add_ideas = {
			SER_YUG_anti_serb_rebellion
			war_economy
			closed_economy
			service_by_requirement
		}
		set_war_support = 0.9
		set_popularities = {
			totalist = 0
			radical_socialist = 20
			syndicalist = 5
			social_democrat = 10
			social_liberal = 0
			market_liberal = 3
			social_conservative = 30
			authoritarian_democrat = 30
			paternal_autocrat = 1
			national_populist = 1
		}
		set_party_name = {
			ideology = social_conservative
			name = SER_muslim_national_organisation
			long_name = SER_muslim_national_organisation_long
		}
		division_template = {
			name = "Bosansko domobranstvo"
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }
			}
		}
		104 = {
			create_unit = {
				division = "division_template = \"Bosansko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Bosansko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Bosansko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Bosansko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Bosansko domobranstvo\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
		}
	}
	declare_war_on = {
		target = BOS
		type = annex_everything
	}
	set_province_controller = 6983
	set_province_controller = 3985
	set_province_controller = 9586
	set_province_controller = 9588
	set_province_controller = 6957
	set_province_controller = 11845
}
YUG_spawn_socialist_rebellion = {
	create_dynamic_country = {
		original_tag = SER
		copy_tag = SER

		set_cosmetic_tag = ASOS
		save_global_event_target_as = ASOS_uprising

		set_politics = {
			ruling_party = syndicalist
			elections_allowed = no
		}
		add_ideas = {
			SER_YUG_anti_serb_rebellion
			war_economy
			closed_economy
			service_by_requirement
		}
		set_war_support = 0.9
		set_popularities = {
			totalist = 0
			radical_socialist = 20
			syndicalist = 40
			social_democrat = 10
			social_liberal = 20
			market_liberal = 5
			social_conservative = 5
			authoritarian_democrat = 0
			paternal_autocrat = 0
			national_populist = 0
		}
		set_party_name = {
			ideology = syndicalist
			name = SER_asos_srp
			long_name = SER_asos_long
		}
		set_party_name = {
			ideology = radical_socialist
			name = SER_asos_srp
			long_name = SER_asos_long
		}
		set_party_name = {
			ideology = social_democrat
			name = SER_asos_sps
			long_name = SER_asos_long
		}
		set_party_name = {
			ideology = social_liberal
			name = SER_asos_srs
			long_name = SER_asos_long
		}
		set_party_name = {
			ideology = market_liberal
			name = SER_asos_nrs
			long_name = SER_asos_long
		}
		set_party_name = {
			ideology = social_conservative
			name = SER_asos_zs
			long_name = SER_asos_long
		}
		add_state_core = 105
		add_state_core = 106
		add_state_core = 765
		transfer_state = 105
		transfer_state = 106
		transfer_state = 765
		set_capital = { state = 105 }

		division_template = {
			name = "Proleterska udarna brigada"
			division_names_group = SER_INF_01
			is_locked = yes
			regiments = {
				infantry = { x = 0 y = 0 }
				infantry = { x = 0 y = 1 }
				infantry = { x = 0 y = 2 }
				infantry = { x = 1 y = 0 }
				infantry = { x = 1 y = 1 }
				infantry = { x = 1 y = 2 }
				infantry = { x = 2 y = 0 }
				infantry = { x = 2 y = 1 }
			}
			support = {
				recon = { x = 0 y = 0 }
			}
		}
		105 = {
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				owner = PREV
			}
		}
		875 = {
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				prioritize_location = 11787
				owner = PREV
			}
			create_unit = {
				division = "division_template = \"Proleterska udarna brigada\" start_experience_factor = 0.3"
				allow_spawning_on_enemy_provs = yes
				prioritize_location = 11787
				owner = PREV
			}
		}
	}
	SER_vukasin_markovic = { set_nationality = event_target:ASOS_uprising }
	SER_konstantin_popovic = { set_nationality = event_target:ASOS_uprising }
	MNT = { MNT_blazo_jovanovic = { set_nationality = event_target:ASOS_uprising } }
	event_target:ASOS_uprising = {
		SER_vukasin_markovic = {
			promote_character = totalist_subtype
			promote_character = syndicalist_subtype
			if = {
				limit = { is_unit_leader = no }
				add_corps_commander_role = {
					desc = SER_vukasin_markovic_leader_desc
					traits = { harsh_leader guerilla_fighter politically_connected }
					skill = 2
					attack_skill = 2
					defense_skill = 2
					planning_skill = 1
					logistics_skill = 2
				}
			}
		}
	}
	transfer_units_fraction = {
		target = event_target:ASOS_uprising
		target_organization = 1
		source_organization = 1
		size = 0.3
		navy_ratio = 0
		keep_unit_leaders_trigger = { always = yes }
	}
	declare_war_on = {
		target = event_target:ASOS_uprising
		type = annex_everything
	}
	event_target:ASOS_uprising = {
		set_province_controller = 9906
		set_province_controller = 13560
		set_province_controller = 6953
		set_province_controller = 3627
		set_province_controller = 11787
	}
	set_province_controller = 6940
	set_province_controller = 11832
	set_province_controller = 907
	set_province_controller = 6886
}

SER_spawn_drina_divisions = {
	every_owned_state = {
		limit = {
			has_state_flag = SER_drina_flagged_state
			is_controlled_by = owner
		}
		add_dynamic_modifier = { modifier = SER_drina_plan_modifier }
		if = {
			limit = { check_variable = { SER.SER_drina_plan_divisions > 0 } }
			if = {
				limit = { SER = { has_socialist_government = yes } }
				create_unit = {
					division = "division_template = \"Srpski partizani\" start_experience_factor = 0.15 start_equipment_factor = 0.9"
					owner = SER
					allow_spawning_on_enemy_provs = yes
					count = SER.SER_drina_plan_divisions
				}
			}
			else = {
				create_unit = {
					division = "division_template = \"Srpska četa\" start_experience_factor = 0.15 start_equipment_factor = 0.9"
					owner = SER
					allow_spawning_on_enemy_provs = yes
					count = SER.SER_drina_plan_divisions
				}
			}
		}
		clr_state_flag = SER_drina_flagged_state
	}
}

SER_remove_yugoslavia = {
	if = {
		limit = {
			OR = {
				has_cosmetic_tag = YUG_mon
				has_cosmetic_tag = YUG_fed
				has_cosmetic_tag = YUG_rep
			}
		}
		if = {
			limit = {
				original_tag = SER
				is_monarchy = no
			}
			set_cosmetic_tag = SER_republic
		}
		else = {
			drop_cosmetic_tag = yes
		}
		SER_disable_yugoslavia_integration = yes
		clr_country_flag = YUG_integral_yugoslavia_formed
		clr_country_flag = YUG_royal_federal_yugoslavia_formed
		clr_country_flag = YUG_usy_formed
		clr_country_flag = YUG_balkan_socialist_federation_formed
		clr_country_flag = YUG_three_named_nation_formed
		if = {
			limit = { has_completed_focus = SER_YUG_integral_yugoslavia }
			uncomplete_national_focus = { focus = SER_YUG_integral_yugoslavia uncomplete_children = yes }
		}
		if = {
			limit = { has_completed_focus = SER_YUG_royal_federation }
			uncomplete_national_focus = { focus = SER_YUG_royal_federation uncomplete_children = yes }
		}
		if = {
			limit = { has_completed_focus = SER_YUG_united_states }
			uncomplete_national_focus = { focus = SER_YUG_united_states uncomplete_children = yes }
		}
		if = {
			limit = { has_completed_focus = SER_YUG_balkan_federalism }
			uncomplete_national_focus = { focus = SER_YUG_balkan_federalism uncomplete_children = yes }
		}
		if = {
			limit = { has_completed_focus = SER_YUG_three_named_nation }
			uncomplete_national_focus = { focus = SER_YUG_three_named_nation uncomplete_children = yes }
		}
	}
}

SER_puppet_crown_petar_effect = {
	if = {
		limit = { has_character = SER_petar_ii }
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = social_democrat_subtype
			}
			promote_leader = yes
		}
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = social_liberal_subtype
			}
			promote_leader = yes
		}
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = market_liberal_subtype
			}
			promote_leader = yes
		}
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = social_conservative_subtype
			}
			promote_leader = yes
		}
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = authoritarian_democrat_subtype
			}
			promote_leader = yes
		}
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = paternal_autocrat_subtype
			}
			promote_leader = yes
		}
		add_country_leader_role = {
			character = SER_petar_ii
			country_leader = {
				desc = SER_petar_ii_leader_desc
				ideology = national_populist_subtype
			}
			promote_leader = yes
		}
	}
}

SER_puppet_dethrone_petar_effect = {
	if = {
		limit = { has_character = SER_petar_ii }
		SER_petar_ii = {
			hidden_effect = { remove_all_country_leader_roles = yes }
			#retire = yes
		}
	}
}
